#Load the library and Create Reference to Library object 
require 'test\unit'
require 'watir'
include Watir
include Test::Unit::Assertions

# define variables
testURL = 'http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/Rating/Rating.aspx'
def checkList(listId, ie)
  i=0;
  a = Array.new(ie.select_list(:id, listId).getAllContents)
  size = a.size
  while i<size do
    ie.select_list(:id,listId).set(a[i])
    assert_equal(a[i], ie.select_list(:id,listId).value)
    i=i+1
  end
  return
end

puts 'tests execution started'

1.times do
  ie = Watir::IE.new
  ie.goto testURL
  checkList('ctl00_SampleContent_lstAlign', ie)
  sleep (2)
  ie.button(:id,'ctl00_SampleContent_btnSubmit').click
  sleep (5)
  assert_not_equal("[No response provided yet]", ie.text_field(:id, 'ctl00_SampleContent_lblResponse').text)
  checkList('ctl00_SampleContent_lstDirection',ie)
  sleep (2)
  ie.button(:id,'ctl00_SampleContent_btnSubmit').click
  sleep (5)
  assert_not_equal("[No response provided yet]", ie.text_field(:id, 'ctl00_SampleContent_lblResponse').text)
  ie.close   
  ie.span(:id, 'ctl00_SampleContent_ThaiRating_Star_1').click
  #  puts(ie.hidden(:id, 'ctl00$SampleContent$ThaiRating_RatingExtender_ClientState').value)
  #  ie.span(:id, 'ctl00_SampleContent_ThaiRating_Star_2').click
  #  puts(ie.hidden(:id, 'ctl00_SampleContent_ThaiRating_RatingExtender_ClientState').value)
  #  ie.span(:id, 'ctl00_SampleContent_ThaiRating_Star_3').click
  #  puts(ie.hidden(:id, 'ctl00_SampleContent_ThaiRating_RatingExtender_ClientState').value)
  #  ie.span(:id, 'ctl00_SampleContent_ThaiRating_Star_4').click
  #  puts(ie.hidden(:id, 'ctl00_SampleContent_ThaiRating_RatingExtender_ClientState').value)
  #  ie.span(:id, 'ctl00_SampleContent_ThaiRating_Star_5').click
  #  puts(ie.hidden(:id, 'ctl00_SampleContent_ThaiRating_RatingExtender_ClientState').value)
  
end
puts 'tests execution finished'